package Controller.CustomerCompany;
import Service.CustomerCompanyService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "deleteCustomerCompany", value = "/deleteCustomerCompany")
public class DeleteCustomerCompany extends HttpServlet {
    private CustomerCompanyService customerCompanyService = new CustomerCompanyService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer id = Integer.valueOf(request.getParameter("id"));
        try{
            customerCompanyService.deleteCustomerCompany(id);
            request.getRequestDispatcher("/ListCustomerCompany").forward(request,response);
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}